﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using UI.WebPage.Background;
using BLL.AuthModel;
using Model.AuthModel;
using Com.Ompchina.Lib.Net;
namespace Com.Ompchina.Web.admin.system
{
    public partial class list_module : ListInfoPage, IListInfo
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack && PageAction.Equals("list")) { this.InitParameter(); }
        }

        #region IListPage 成员

        public void InitParameter()
        {
            ddlType.DefaultSelect = RequestParam.GetString(Request, "typeid");
            txtKey.Text = Server.UrlDecode(RequestParam.GetString(Request, "key"));
        }

        public void ExecuteUpdate()
        {
            throw new NotImplementedException();
        }

        #endregion

        /// <summary>
        /// 获取模块
        /// </summary>
        /// <param name="pageSize"></param>
        /// <param name="recordCount"></param>
        /// <returns></returns>
        protected IList<ModuleInfo> _GetModule(int pageSize, out int recordCount)
        {
            return new ModuleBLL().ListModule(int.Parse(ddlType.SelectedValue)
                , Server.HtmlEncode(txtKey.Text.Trim())
                , PageIndex, pageSize, out recordCount);
        }

        protected void txtSearch_Click(object sender, EventArgs e)
        {
            if (ddlType.SelectedIndex > 0 || !string.IsNullOrEmpty(txtKey.Text.Trim()))
            {
                base.Redirect(string.Format(Request.Url.AbsolutePath + "?action=list&typeid={0}&key={1}"
            , ddlType.SelectedValue, Server.UrlEncode(txtKey.Text)), 0);
            }
        }
    }
}
